package com.review.test;

/**
 * Created by xjweng on 2017/2/4.
 */
public class ComparableCircle extends Circle implements CompareObject {
    public ComparableCircle(double radius) {
        super(radius);
    }
    //比较两个圆半径
    @Override
    public int compareTo(Object o) {
        if ( o instanceof Circle){
            Circle cir = (Circle) o;
            return (int)(this.getRadius() - cir.getRadius());
        }else{
            throw new CircleClassException("notCircle");
        }
    }
}
class ComparableRectangle extends Rectangle implements CompareObject {
    public ComparableRectangle(double width, double height) {
        super(width, height);
    }

    @Override
    public int compareTo(Object o) {
        if (o instanceof Rectangle){
            Rectangle rect = (Rectangle) o;
            return (int)(this.findAreas() - rect.findAreas());
        }
        return 0;
    }
}
